#ifndef LUCNX_GLOBAL_H
#define LUCNX_GLOBAL_H

#include <Lucnx/types.h>

#define SELECTOR_KERL_CODE (1 << 3)
#define SELECTOR_KERL_DATA (2 << 3)

#define SELECTOR_USER_CODE (4 << 3) | (0b11)
#define SELECTOR_USER_DATA (5 << 3) | (0b11)

#define SELECTOR_TSS (3 << 3)

#define TSS_ATTR 0b10001001
#define K_CODE_ATTR 0b110010011010
#define K_DATA_ATTR 0b110010010010

#define U_CODE_ATTR 0b110011111010
#define U_DATA_ATTR 0b110011110010

typedef struct pointer_t
{
    u16 limit;
    u32 base;
}pointer_t;

typedef struct global_t
{
    u16 limit1;
    u16 base1;
    u8 base2;
    u8 attr1;
    u8 limit2_attr2;
    u8 base3;
}_packed global_t;

typedef struct tss_t
{
    u32 task_link;
    u32 esp0;
    u32 ss0;
    u32 esp1;
    u32 ss1;
    u32 esp2;
    u32 ss2;
    u32 cr3;
    u32 eip;
    u32 eflsgs;
    u32 eax;
    u32 ecx;
    u32 edx;
    u32 ebx;
    u32 esp;
    u32 ebp;
    u32 esi;
    u32 edi;
    u32 es;
    u32 cs;
    u32 ss;
    u32 ds;
    u32 fs;
    u32 gs;
    u32 ldt_selector;
    u32 iomap;
}tss_t;

u32 get_cr2();
u32 get_cr0();

#endif